# -*- coding: utf-8 -*-
"""
Created on Thu Jul 18 18:08:12 2019

@author: admin

"""

#清洗数据，防止None出现
def data_clean(source):
    data = source['_source']
    if not data['prj_name']:
        data['prj_name'] = '-1'
    if not data['prj_id']:
        data['prj_id'] = '-1'
    if not data['deal_time']:
        data['deal_time'] = '-1'
    if not data['customer'][0]['name']:
        data['customer'][0]['name'] = '-1'
    if not data['supplier'][0]['name']:
        data['supplier'][0]['name'] = '-1'
    if not data['budget']:
        data['budget'] = float(-1)
    if not data['bid_price']:
        data['bid_price'] = float(-1)
    source['_source'] = data
    return source

if __name__ == '__main__':   
    es_access = 'http://47.112.138.184:9202'
    es_index = 'projecttest2'
    doc_type='_doc'    
    
    
    